package jp.co.ufp;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class AkiraNDKActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);
	/*
	 * Create a TextView and set its content. the text is retrieved by
	 * calling a native function.
	 */
	TextView textNdk = (TextView) findViewById(R.id.textNdk);
	textNdk.setText(stringFromJNI());
	setHogeObject();
    }

    /*
     * A native method that is implemented by the 'hello-jni' native library,
     * which is packaged with this application.
     */
    public native String stringFromJNI();

    /*
     * This is another native method declaration that is *not* implemented by
     * 'hello-jni'. This is simply to show that you can declare as many native
     * methods in your Java code as you want, their implementation is searched
     * in the currently loaded native libraries only the first time you call
     * them.
     * 
     * Trying to call this function will result in a
     * java.lang.UnsatisfiedLinkError exception !
     */
    public native String unimplementedStringFromJNI();

    protected static native void setHogeObject();

    protected static void setHoge(int value) {
	Log.i("Test", "Native,Hoge=" + value);
    }

    /*
     * this is used to load the 'hello-jni' library on application startup. The
     * library has already been unpacked into
     * /data/data/com.example.HelloJni/lib/libhello-jni.so at installation time
     * by the package manager.
     */
    static {
	System.loadLibrary("hello-jni");
    }
}